package com.sbl.bajw.pc.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sbl.bajw.pc.model.XSJQModel;
import com.sbl.bajw.pc.service.XSJQModelService;
import com.sbl.bajw.util.JsonUtil;

@Controller
@RequestMapping("/XSJQModel")
public class XSJQModelAction {
	
	@Resource
	private XSJQModelService service;
	
	@RequestMapping("/getXSJQModel")
	public @ResponseBody String getXSJQModel(HttpServletRequest request, HttpServletResponse response) throws Exception{
		String level = request.getParameter("level");
		HashMap<String, Object> parm = new HashMap<String, Object>();
		if(level != null && !level.equals("")){
			parm.put("level", "%" + level + "%");
		}
		List<XSJQModel> list = service.getXSJQModel(parm);
		String json = JsonUtil.ConvertArrayToJson(list);
		return json;
	}
	
	@RequestMapping("/getCountByAlarmLevel")
	public @ResponseBody String getCountByAlarmLevel(HttpServletRequest request, HttpServletResponse response) throws Exception{
		List<Map<String, String>> list = service.getCountByAlarmLevel();
		String json = JsonUtil.ConvertArrayToJson(list);
		return json;
	}
}
